
<?php if(!isset($args['data']['posts']) || empty($args['data']['posts'])) 

?>

<div class="posts gridpost fx fxwrap <?php if(isset($args['special']) && $args['special']){echo 'special';}?>" <?php if(!isset($args['data']['posts']) || empty($args['data']['posts'])) echo 'style="grid-template-columns:none;"'?> >
    <?php if (isset($args['data']['posts']) && is_array($args['data']['posts']) && !empty($args['data']['posts'])) : ?>
        <?php foreach ($args['data']['posts'] as $post) : ?>
            <div class="item fx brds">
            <div class="item_info fx fxcolumn gap fx_ai_end">
                <h2 class="nowrap2 ala"><a href="<?php echo $post['link']; ?>"><?php echo $post['title']; ?></a></h2>
                <a class="fx fx_ai_center" href="<?php echo $post['link']; ?>" title="<?php echo $post['title']; ?>" >
                    <img class="brds"  data-src="<?php echo $post['thumbnail']; ?>" alt="<?php echo $post['title']; ?>">
                </a>
                <span class="item_time btn ala"><?php echo $post['date']; ?></span>
            </div>
        </div>
        <?php endforeach; ?>
    <?php else : ?>
        <?php if (isset($args['showEmpty']) && $args['showEmpty']) : ?>
            <p class="empty-message">لا توجد منشورات متاحة حاليا.</p>
        <?php endif; ?>
    <?php endif; ?>
</div>

<?php if (isset($args['showPage']) && $args['showPage'] && isset($args['data']['pagination']['total_pages']) && $args['data']['pagination']['total_pages'] > 1) : ?>
    <div class="pagination">
        <?php
        echo paginate_links(array(
            'total' => $args['data']['pagination']['total_pages'],
            'current' => $args['data']['pagination']['current_page'],
            'prev_text' => __('«'),
            'next_text' => __('»'),
        ));
        ?>
    </div>
<?php endif; ?>


